//
//  ProductDetailModel.swift
//  koolcar
//
//  Created by kuaimaxiansheng on 2023/10/26.
//

import UIKit

import ObjectMapper
class ProductDetailModel: Mappable {
    var code: String?
    var msg: String?
    var data: DetailModel?
    func mapping(map: Map) {
        code <- map["code"]
        msg <- map["msg"]
        data <- map["data"]
    }
    required init?(map: Map) {
    }
    
}

class DetailModel: Mappable {
    var data: ProductDetailDataModel?
    var parameters: [ParametersModel]?
    func mapping(map: Map) {
        data <- map["data"]
        parameters <- map["parameters"]
    }
    required init?(map: Map) {
    }
    
}



class ProductDetailDataModel: Mappable {
    
    var selectSpecificationBlock: (()->Void)?//选择规格
    var parameters: [ParametersModel]?
    var applyCar: String?//适用车款
    var categoryId: Int?//商品分类id
    var categoryName: String?//商品分类
    var createdTime: String?
    var id: Int?
    var isShelf: Bool?//是否上架  true 上架
    var isTop: Int?
    var name: String?//商品名称
    var originalPrice: Double?//原价
    var price: Double?//price
    var productDecr: String?//商品描述
    var productImages: String?//商品图片
    var productMoreInfo: String?//更多信息
    var productNo: String?//商品编号
    var skuDTOList: [SkuDTOListModel]?//商品信息
    var stock: Int?//库存
    var memberPrice: Double?
    var isFavorite: Bool?//是否加入收藏
    var shareText: String?//分享
    var isLimitedTime: Int?//限时抢购：1
    var activityTime: NSInteger?
    var isSellOut: Bool?
    var isValid: Bool?//false 失效商品
    var deliveryAndHandle: String?//运送及处理
    var discountPrice: Double?
    
    var itemTitle: String?//标题
    var titile: String?//标题
    var content: String?//内容
    var section: NSInteger?
    var width: Double = 0
    
    func mapping(map: Map) {
        applyCar <- map["applyCar"]
        categoryId <- map["categoryId"]
        categoryName <- map["categoryName"]
        createdTime <- map["createdTime"]
        id <- map["id"]
        isLimitedTime <- map["isLimitedTime"]
        isShelf <- map["isShelf"]
        isTop <- map["isTop"]
        name <- map["name"]
        originalPrice <- map["originalPrice"]
        price <- map["price"]
        productDecr <- map["productDecr"]
        productImages <- map["productImages"]
        productMoreInfo <- map["productMoreInfo"]
        productNo <- map["productNo"]
        stock <- map["stock"]
        skuDTOList <- map["skuDTOList"]
        memberPrice <- map["memberPrice"]
        isFavorite <- map["isFavorite"]
        shareText <- map["shareText"]
        activityTime <- map["activityTime"]
        isSellOut <- map["isSellOut"]
        isValid <- map["isValid"]
        deliveryAndHandle <- map["deliveryAndHandle"]
        discountPrice  <- map["discountPrice"]

    }
    required init?(map: Map) {
    }
    
    init () {
        
    }
}

class ParametersModel: Mappable {
    var id: NSInteger?
    var createdTime: String?
    var modifyTime: String?
    var version: String?
    var delFlag: String?
    var name: String?
    var items: [ItemsModel]?
  
    func mapping(map: Map) {
        id <- map["id"]
        createdTime <- map["createdTime"]
        modifyTime <- map["modifyTime"]
        version <- map["version"]
        delFlag <- map["delFlag"]
        name <- map["name"]
        items <- map["items"]
    }
    required init?(map: Map) {
    }
}


class ItemsModel: Mappable {
    var id: Int?
    var createdTime: String?
    var modifyTime: String?
    var version: String?
    var delFlag: String?
    var name: String?
    var parameterId: Int?
    var able: Bool?
    var select: Bool?
    func mapping(map: Map) {
        id <- map["id"]
        createdTime <- map["createdTime"]
        modifyTime <- map["modifyTime"]
        version <- map["version"]
        delFlag <- map["delFlag"]
        name <- map["name"]
        parameterId <- map["parameterId"]
    }
    required init?(map: Map) {
        
    }
    init() {
        able = false
        select = false
    }
}



class SkuDTOListModel: Mappable {
    var id: NSInteger?
    var createdTime: String?
    var skuNo: String?
    var price: Double?//售价
    var originalPrice: Double?//原价
    var memberPrice: Double?//会员价
    var stock: Int?//库存
    var stockLock: Int?//
    var sortNo: String?//
    var availableStock: NSInteger?//可用库存
    var parameterItems: [SpecificationModel]?//规格
    var name: String?
    var paramIds: String? //id组合
    var discountPrice: Double?//特价
    func mapping(map: Map) {
        name <- map["name"]
        id <- map["id"]
        createdTime <- map["createdTime"]
        skuNo <- map["skuNo"]
        price <- map["price"]
        originalPrice <- map["originalPrice"]
        stock <- map["stock"]
        stockLock <- map["stockLock"]
        sortNo <- map["sortNo"]
        availableStock <- map["availableStock"]
        parameterItems <- map["parameterItems"]
        paramIds <- map["paramIds"]
        memberPrice <- map["memberPrice"]
        discountPrice <- map["discountPrice"]
    }
    required init?(map: Map) {
        
    }
    
    init(){
        paramIds = ""
    }
    
}


class SpecificationModel: Mappable {
    var id: Int?
    var name: String?
    var parameterId: NSInteger?
    var parameterName: String?//售价
   
    func mapping(map: Map) {
        id <- map["id"]
        parameterId <- map["parameterId"]
        parameterName <- map["parameterName"]
        name <- map["name"]
    }
    required init?(map: Map) {
    }
    
}
